package net.oschina.app.adapter.me.noticeadapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import net.oschina.app.R;
import net.oschina.app.base.BaseListAdapter;
import net.oschina.app.base.Global;
import net.oschina.app.bean2.FriendBean;

/**
 * Created by Shinelon on 2017/1/15.
 */

public class NoticeListAdapter1 extends BaseListAdapter<FriendBean> {
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(Global.mContext).inflate(R.layout.item_me_notice_common,parent,false);
        NoticeHolder1 holder = new NoticeHolder1(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        FriendBean  data =  mList.get(position);
        ((NoticeHolder1)holder).tvName.setText(data.getName());
        ((NoticeHolder1)holder).tvFrom.setText(data.getFrom());
        ((NoticeHolder1)holder).tvExpertise.setText(data.getExpertise());
        //((NoticeHolder1)holder).ivGenter.setImageResource(data.getGender());
        if (data.getGender() == 1) {
            ((NoticeHolder1) holder).ivGenter.setBackground(Global.
                    mContext.getResources().getDrawable(R.drawable.userinfo_icon_male));
        } else if (data.getGender() == 2){
            ((NoticeHolder1) holder).ivGenter.setBackground(Global.
                    mContext.getResources().getDrawable(R.drawable.userinfo_icon_female));
        }
    }

    class NoticeHolder1 extends RecyclerView.ViewHolder{
        public TextView tvName;
        public TextView tvFrom;
        public TextView tvExpertise;
        public ImageView ivGenter;
        public NoticeHolder1(View itemView) {
            super(itemView);
            tvName = (TextView) itemView.findViewById(R.id.tv_name);
            tvFrom = (TextView) itemView.findViewById(R.id.tv_from);
            tvExpertise = (TextView) itemView.findViewById(R.id.tv_expertise);
            ivGenter = (ImageView) itemView.findViewById(R.id.iv_genter);
        }
    }
}
